package com.hhh.springai_test.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hhh.springai_test.model.po.User;
import org.apache.ibatis.annotations.Select;

public interface UserMapper extends BaseMapper<User> {
    
    // 获取今天新增用户数
    @Select("SELECT COUNT(*) FROM user WHERE DATE(createTime) = CURDATE() AND isDelete = 0")
    Long getTodayNewUsers();
    
    // 获取近三天新增用户数
    @Select("SELECT COUNT(*) FROM user WHERE createTime >= DATE_SUB(CURDATE(), INTERVAL 3 DAY) AND isDelete = 0")
    Long getLastThreeDaysNewUsers();
    
    // 获取近一周新增用户数
    @Select("SELECT COUNT(*) FROM user WHERE createTime >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK) AND isDelete = 0")
    Long getLastWeekNewUsers();
    
    // 获取近一个月新增用户数
    @Select("SELECT COUNT(*) FROM user WHERE createTime >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND isDelete = 0")
    Long getLastMonthNewUsers();
}
